package cn.platform.mapper;

import cn.platform.entity.Student;
import cn.platform.entity.UserAccount;
import cn.platform.request.IdentifyRequest;
import cn.platform.request.Student.StudentQueryDTO;
import cn.platform.request.Student.StudentQueryDTO;
import cn.platform.request.StudentRequest;
//import cn.platform.response.StudentVO;
import cn.platform.response.StudentVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import cn.platform.request.UserStudentQueryDTO;
import cn.platform.response.StudentVO;
import cn.platform.response.UserStudentVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {
    // 登录身份验证
    List<UserAccount> identify(IdentifyRequest req);

    // 查询
    List<Student> listStudent(StudentRequest req);

    // 新增
    void insertStudent(StudentRequest req);

    // 更新，用id找，其余参数为更新内容，null值不更新
    void updateStudent(StudentRequest req);

    // 删除，用id找
    void deleteStudent(StudentRequest req);


//    List<UserStudentVO> page(UserStudentQueryDTO userStudentQueryDTO);
    List<UserStudentVO> page(UserStudentQueryDTO userStudentQueryDTO);

    void insert(Student student);

    void update(Student student);

    Integer countWithParentId(List<Integer> ids);

    @Delete("delete from jxt_students where id=#{id}")
    void deleteById(Integer id);

    void batchDeleteById(List<Integer> ids);

    @Select("select real_name from jxt_students where id=#{studentId}")
    Student selectById(Integer studentId);

    @Select("select count(1) from jxt_students where class_id=#{id}")
    int getCountByClassId(String id);



    List<Student> listAllActiveStudents();


    //学生成绩关联
    @Select("select * from jxt_students where id=#{id} ")
    Student getById(Integer studentId);


    @Select("select real_name from jxt_students where id=#{id} ")
    String getNameById(Integer studentId);


    @Select("SELECT id, real_name FROM jxt_students WHERE real_name LIKE CONCAT('%', #{name}, '%')")
   List<Student> searchByName(String name);

    @Select("SELECT id, real_name FROM jxt_students")
    List<Student> getAll();
}
